<?php
/**
 * Created by 豆豆.
 * mail longrbl@163.com
 * User: Administrator
 * Date: 2018/1/15
 * Time: 14:48
 */

namespace style\lib;


class Task_Ctlr
{
  public $data = '';
  public $service = '';
  public $task_service = '';

  function __construct($data, $service, $task_service)
  {
    $this->data = $data;//task 异步任务要处理的数据
    $this->service = $service; //swoole_http_service实例化对象
    $this->task_service = $task_service;//src_worker_id来自于哪个worker进程,task_id是任务ID
  }

  /**
   * @param $data 把数据返回给worker进程阻塞模式下
   */
  function _return($data)
  {
    $this->service->finish(json_encode($data));
  }

  /**
   * @return mixed 返回数据库对象
   */
  function db()
  {
    return $this->service->db;
  }


}